package com.wframe.project.jnd.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.frame.database.JdataBean;
import com.frame.database.PageResult;
import com.wframe.framework.database.BaseDao;

@Repository
public class FloorDao extends BaseDao{

	public List<JdataBean> queryFloor(Integer status){
		return querySql("select * from wb_floor where status=? order by orderno,id", new Object[]{status});
	}
	public List<JdataBean> queryFloorItem(String floorid){
		return querySql("select * from wb_floor_item where floorid=? order by orderno is null asc,orderno,id", new Object[]{floorid});
	}
	
	public JdataBean getFloor(String id){
		return getObject("select * from wb_floor where id=?", new Object[]{id});
	}
	public JdataBean getFloorItem(String id){
		return getObject("select * from wb_floor_item where id=?", new Object[]{id});
	}

	public List<JdataBean> queryFloorItems(List<String> floorIds) {
		StringBuffer sql = new StringBuffer("select * from wb_floor_item where floorid in (");
		Object[] objArr = new Object[floorIds.size()];
		for(int i = 0 ; i < floorIds.size() ; i++) {
			if(i == 0) {
				sql.append("?");
			}else {
				sql.append(",?");
			}
			objArr[i] = floorIds.get(i);
		}
		sql.append(") order by orderno is null asc,orderno,id");
		return querySql(sql.toString(),objArr);
	}
}
